package org.jprobe.ui;

import java.awt.BorderLayout;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import org.jprobe.JProbeException;
import org.jprobe.JProbeRuntimeException;
import org.jprobe.Settings;
/**
*
* @author Hussain Al-Mutawa
* @version 1.0
* @since 1.0
*/
@SuppressWarnings("serial")
public class MainPanel extends JPanel {

	/**
	 * initializes new Main Panel
	 */
	public MainPanel() {
		super();

		final ProjectExplorerPanel projExpPanel = new ProjectExplorerPanel();
		final Settings settings = new Settings();

		try {
			settings.readSettingsFromFile("settings.xml");
		} catch (final JProbeException exception) {
			throw new JProbeRuntimeException(exception);
		}
		final ProjectsViewerPanel projectsViewer = new ProjectsViewerPanel(settings){
			@Override
			public void projectChanged(String project) {
				projExpPanel.setCurrentProject(project);
			}
		};


		setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
		setLayout(new BorderLayout(3,3));
		final JTabbedPane tabbed = new JTabbedPane(1);
		add(projectsViewer,BorderLayout.WEST);
		add(tabbed,BorderLayout.CENTER);
		tabbed.addTab("Project Explorer", projExpPanel);
		projExpPanel.showResults();
	}
}
